﻿function GetUrl(typeName) {
    switch (typeName) {
        case "客源新增":
            typeName = "../../AM/Customer_List.aspx?reporttypeid=0";
            break;
        case "盘源新增":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=0";
            break;
        case "有效客源跟进":
            typeName = "../../AM/CustomerFollowList.aspx?";
            break;
        case "有效盘源跟进":
            typeName = "../../AM/HousingFollowList.aspx?flwtype=1";
            break;
        case "钥匙":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=20";
            break;
        case "摆台":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("摆台") + "";
            break;
        case "成交后服务":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("成交后服务") + "";
            break;
        case "诚意金":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("诚意金") + "";
            break;
        case "带看房":
            //typeName = "../../AM/CustomerFollowList.aspx?ftype="+escape("带看房")+"";
            typeName = "~/../../Quantify/Report/lp_ForSale.aspx?ftype=" + escape("带看房") + "";
            break;
        case "独家委托":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=2";
            break;
        case "反签":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=3";
            break;
        case "家访":
            typeName = "../../AM/HousingFollowList.aspx?flwtype=21"; //http: //localhost:41075/AM/HousingFollowList.aspx?salesmanid=20089&addDate1=2012-04-19&addDate2=2012-04-19&flwtype=21
            break;
        case "自看房":
            typeName = "../../AM/HousingFollowList.aspx?flwtype=2";
            break;
        case "网络推广":
            typeName = "";
            break;
    }
    return typeName;
}

function GetUrl1(typeName) {
    switch (typeName) {
        case "客源新增":
            typeName = "../../AM/Customer_List.aspx?reporttypeid=0";
            break;
        case "盘源新增":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=0";
            break;
        case "有效客源跟进":
            typeName = "../../AM/CustomerFollowList.aspx?";
            break;
        case "有效盘源跟进":
            typeName = "../../AM/HousingFollowList.aspx?flwtype=1";
            break;
        case "钥匙":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=20";
            break;
        case "摆台":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("摆台") + "";
            break;
        case "成交后服务":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("成交后服务") + "";
            break;
        case "诚意金":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("诚意金") + "";
            break;
        case "带看房":
            typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("带看房") + "";
            //typeName = "~/../../Quantify/Report/lp_ForSale.aspx?ftype=" + escape("带看房") + "";
            break;
        case "独家委托":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=2";
            break;
        case "反签":
            typeName = "../../AM/Housing_List.aspx?reporttypeid=3";
            break;
        case "家访":
            typeName = "../../AM/HousingFollowList.aspx?flwtype=21"; //http: //localhost:41075/AM/HousingFollowList.aspx?salesmanid=20089&addDate1=2012-04-19&addDate2=2012-04-19&flwtype=21
            break;
        case "自看房":
            typeName = "../../AM/HousingFollowList.aspx?flwtype=2";
            break;
        case "网络推广":
            typeName = "";
            break;
    }
    return typeName;
}
//原始弹出JS
function AAlert(typename, param, opentype) {
    var Url = GetUrl(typename);

    if (Url != '') {
        if (opentype == '1') {
            var style = "resizable = yes, scrollbars = yes,width=800px, height=650px,Toolbar=no,Location=no,Direction=no,Resizeable=no";
            window.open(Url + param, typename, style);
        }
        else {
            parent.closeTab(typename);
            parent.addTab(typename, Url + param, "icon-nav");
        }
    }
    else {
        alert('尚未有链接页面，请近期留意。。。');
    }

}
//多一级JS弹出JS
function AAlert1(typename, param, opentype) {
    var Url = GetUrl1(typename);

    if (Url != '') {
        if (opentype == '1') {
            var style = "resizable = yes, scrollbars = yes,width=800px, height=650px,Toolbar=no,Location=no,Direction=no,Resizeable=no";
            window.open(Url + param, typename, style);
        }
        else {
            parent.parent.closeTab(typename);
            parent.parent.addTab(typename, Url + param, "icon-nav");
        }
    }
    else {
        alert('尚未有链接页面，请近期留意。。。');
    }

}
//多一级JS弹出JS
function AAlert2(typename, param, opentype) {
    var Url = GetUrl(typename);

    if (Url != '') {
        if (opentype == '1') {
            var style = "resizable = yes, scrollbars = yes,width=800px, height=650px,Toolbar=no,Location=no,Direction=no,Resizeable=no";
            window.open(Url + param, typename, style);
        }
        else {
            parent.parent.parent.closeTab(typename);
            parent.parent.parent.addTab(typename, Url + param, "icon-nav");
        }
    }
    else {
        alert('尚未有链接页面，请近期留意。。。');
    }

}

function jsweburl() {

    parent.parent.closeTab("我的网店");
    parent.parent.addTab("我的网店", "../Quantify/workurl/lp_myListUrl.aspx", "icon-nav");
}

function jsweburl2() {
    parent.closeTab("我的网店");
    parent.addTab("我的网店", "../Quantify/workurl/lp_myListUrl.aspx", "icon-nav");
}

function returnYesday() {//返回昨日日期
    var today = new Date();            //月份为0-11
    var yesterday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24;
    var yesterday = new Date();
    yesterday.setTime(yesterday_milliseconds);

    var strYear = yesterday.getFullYear();
    var strDay = yesterday.getDate();
    var strMonth = yesterday.getMonth() + 1;
    if (strMonth < 10) {
        strMonth = "0" + strMonth;
    }

    var strYesterday = strYear + "-" + strMonth + "-" + strDay;
    return strYesterday;
}



function chartxs(yesdaychart, text, divid) {//yesdaychar data数据 text标题 divid   饼图点击链接
    chart = new Highcharts.Chart({

        title: {
            text: text
        },
        chart: {
            renderTo: divid,
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            height: 250
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                events: {
                    click: function(e) {
                        parent.parent.closeTab(e.point.name);
                        parent.parent.addTab(e.point.name, e.point.dataLabels, "icon-nav");
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: '得分',
            data: yesdaychart
}]
        });
    }

    function chartxs1(yesdaychart, text, divid, station) {//yesdaychar data数据 text标题 divid   饼图点击链接
        chart = new Highcharts.Chart({

            title: {
                text: text
            },
            chart: {
                renderTo: divid,
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                height: 250
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    events: {
                        click: function(e) {

                            if (returnTF(station) == true) {
                                parent.closeTab(e.point.name);
                                parent.addTab(e.point.name, e.point.dataLabels, "icon-nav");
                            }
                        }

                    }
                }
            },
            series: [{
                type: 'pie',
                name: '得分',
                data: yesdaychart
}]
            });
        }

        function returnTF(obj) {//无法点击饼图
            if (obj == '置业顾问' || obj == '跑盘员' || obj == '业务主任' || obj == '高级跑盘员') {
                return false;
            }
            else {
                return true;
            }
        }


        function chartxsDeptlist(yesdaychart, text, divid, ismanager) {//yesdaychar data数据 text标题 divid   饼图点击链接  是否可点

            chart = new Highcharts.Chart({

                title: {
                    text: text
                },
                chart: {
                    renderTo: divid,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false,
                    height: 250
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        events: {
                            click: function(e) {

                                if (ismanager == 1) {
                                    parent.closeTab(e.point.name);
                                    parent.addTab(e.point.name, e.point.dataLabels, "icon-nav");
                                }
                                if (ismanager == 2) {
                                    parent.parent.closeTab(e.point.name);
                                    parent.parent.addTab(e.point.name, e.point.dataLabels, "icon-nav");
                                }
                            }
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: '得分',
                    data: yesdaychart
}]
                });
            }

            function GetDeptType(depttype) {
            
                if (depttype == '营业大部' || depttype == '营业部' || depttype == '区域' || depttype == '后勤')
                { return true; }
                else
                    return false;
            }